package com.day08.homework;

import com.day08.homework.dao.DAOFactory;
import com.day08.homework.vo.Book;

import java.sql.Date;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<Book> list = null;
        try {
            list = DAOFactory.getIBookDaoInstance().selectBookInfoAll();
            for (Book book : list) {
                System.out.println("1--" + book.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println();
        try {
            System.out.println("2--" + DAOFactory.getIBookDaoInstance().insertBookInfo(new Book(3, "312312312", "Java从入门到放弃", 100, new Date(new java.util.Date().getTime()))));
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            list = DAOFactory.getIBookDaoInstance().selectBookInfoAll();
            for (Book book : list) {
                System.out.println("3--" + book.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println();
        try {
            System.out.println("4--" + DAOFactory.getIBookDaoInstance().deleteBookInfo(3));
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            list = DAOFactory.getIBookDaoInstance().selectBookInfoAll();
            for (Book book : list) {
                System.out.println("5--" + book.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println();
        try {
            System.out.println("6--" + DAOFactory.getIBookDaoInstance().updateBookInfo(1, new Book(3, "312312312", "Java从入门到放弃", 100, new Date(new java.util.Date().getTime()))));
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            list = DAOFactory.getIBookDaoInstance().selectBookInfoAll();
            for (Book book : list) {
                System.out.println("7--" + book.toString());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println();
    }
}
